#include "string_partial_match.h"
#include <iostream>
using std::string;
using std::vector;

void t_string_partial_matches::find_matches(const string& str, vector<unsigned>& matching_results)
{
	string::size_type strlen = str.length();
	for (unsigned i = 0; i < strings.size(); ++i)
	{
		string::size_type pos = strings[i].find(str);
		// not found: ignore
		if (pos == string::npos)
			continue;
		string::size_type remainder = strings[i].length() - pos - strlen;

		// must match from front for FRONT or FULL
		if ((match_modes[i] & eMATCH_FRONT) &&	pos)
			continue;

		// must match from back for BACK or FULL
		if ((match_modes[i] & eMATCH_BACK)  && remainder)
			continue;
		matching_results.push_back(results[i]);
	}
}
